import Vue from 'vue';
import Router from 'vue-router';
import Index from '@/pages/Index';
import Goods from '@/pages/Goods/Goods';
import Register from '@/pages/Register/Register';
import Login from '@/pages/Login/Login';
import Address from '@/pages/Address/Address';
import Buy from '@/pages/Buy/Buy';
import Carts from '@/pages/Carts/Carts';

Vue.use(Router);

export default new Router({
  // mode: 'history',
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  },
  routes: [
    {
      path: '/index',
      name: 'index',
      component: Index
    },
    {
      path: '/',
      redirect: '/index',
      component: Index
    },
    {
      path: '/goods',
      name: 'goods',
      component: Goods
    },
    {
      path: '/register',
      name: 'register',
      component: Register
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/address',
      name: 'address',
      component: Address
    },
    {
      path: '/buy',
      name: 'buy',
      component: Buy
    },
    {
      path: '/carts',
      name: 'carts',
      component: Carts
    }
  ]
})
